package org.gd.jetty;

import org.eclipse.jetty.websocket.WebSocket;

import java.util.Set;

/**
 * @author Gorhover
 * @version 1.0-SNAPSHOT
 * @since 2013-11-13 13:59
 */
public class SimpleWebSocket implements WebSocket.OnTextMessage {

    private Connection connection;
    private Set<SimpleWebSocket> webSockets;

    private SimpleWebSocket(final Set<SimpleWebSocket> webSockets) {
        this.webSockets = webSockets;
    }

    @Override
    public void onMessage(String data) {
    }

    @Override
    public void onOpen(Connection connection) {
        this.connection = connection;
    }

    @Override
    public void onClose(int closeCode, String message) {
        System.out.println("onClose");
        System.out.println("closeCode: " + closeCode);
        System.out.println("message: " + message);
        webSockets.remove(this);
    }
}
